import * as http from 'http';
import app from './app';
import C from '@jingli/config';
import {sendSuccssMsgToCluster, WORKER_BOOT_STATUS } from '@jingli/server';

const server = http.createServer(app);
server.on('error', (err) => {
    sendSuccssMsgToCluster(WORKER_BOOT_STATUS.FAILED);
    console.error(err);
    process.exit(-1);
})

server.on('listening', () => {
    sendSuccssMsgToCluster(WORKER_BOOT_STATUS.SUCCSSED);
    // console.log(`SERVER START...`);
})

server.listen(C.port);
